package com.web;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.entity.User;
import com.service.LoginService;
import com.service.ProjectService;

public class NewProjectServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		LoginService service = new LoginService();
		List<User> userList = service.findAll();
		
		request.setAttribute("userList", userList);
		request.getRequestDispatcher("/WEB-INF/pms/newproject.jsp").forward(request, response);
	}
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String projectname = request.getParameter("projectname");
		String projectcontent = request.getParameter("projectcontent");
		String manager = request.getParameter("manager");
		String worker = request.getParameter("workers");
		
		ProjectService service = new ProjectService();
		service.save(projectname,projectcontent,manager,worker);	
		response.sendRedirect("main.jspx");
		
	
	}
	
	
}
